package org.rkuk.kasutil.uintTest.framework 
{
	import flash.events.EventDispatcher;
	import org.rkuk.kasutil.uintTest.event.TestEvent;
	
	/**
	 * ...
	 * @author rkuk
	 */
	public class TestMethod extends EventDispatcher 
	{
		public static const NULL_TEST_METHOD:TestMethod = new NullTestMethod();
		
		private var isStatic_:Boolean;
		protected var methodName_:String;
		protected var params_:Array;
		protected var isSuccess_:Boolean;
		
		public function TestMethod(methodName:String,isStatic:Boolean,...params) 
		{
			super();
			isStatic_ = isStatic;
			methodName_ = methodName;
			params_ = params;
		}
		
		public function execute(invoker:Object):void
		{
			isSuccess_ = TestEnviorenment.instance.runTest(invoker, methodName_, params_);
			notifyExecuted();
		}
		
		public function get methodName():String
		{
			return methodName_;
		}
		
		public function get isStatic():Boolean
		{
			return isStatic_;
		}
		
		protected function notifyExecuted():void
		{
			dispatchEvent(new TestEvent(TestEvent.EXECUTE));
		}
		
		public function get isSuccess():Boolean
		{
			return isSuccess_;
		}
	}
}
class NullTestMethod extends TestMethod
{
	public function NullTestMethod()
	{
		super("", true);
		isSuccess_ = true;
	}
	
	override public function execute(invoker:Object):void 
	{
		notifyExecuted();
	}
}